package com.lcq.privacysupport;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class ProtocolActivity extends Activity {
    public static final String EXTRA_TITLE = "title";
    public static final String EXTRA_CONTENT = "content";

    @SuppressLint("JavascriptInterface")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initWindow();
        setContentView(R.layout.activity_agreement);
        TextView titleTv = findViewById(R.id.title);
        TextView contentTv = findViewById(R.id.content);

        String title = null;
        String content = null;
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            title = bundle.getString(EXTRA_TITLE);
            content = bundle.getString(EXTRA_CONTENT);
        }
        if (!TextUtils.isEmpty(title)) {
            titleTv.setText(title);
        }

        if (!TextUtils.isEmpty(content)) {
            contentTv.setText(Html.fromHtml(content));
        }
    }

    private void initWindow() {
        Window window = getWindow();
        View decorView = window.getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.setStatusBarColor(Color.TRANSPARENT);
        }
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            getActionBar().hide();
        }
    }
}
